LAGOS Analysis

Loading in data

First download and then specifically grab the locus (or site lat longs)

# #Lagos download script

#Load in lagos
lagos <- lagosne_load(fpath = "/Users/orioncr/Downloads/LAGOSNE/LAGOSNE/data_1.087.3.qs")
## Warning in (function (version = NULL, fpath = NA) : LAGOSNE version unspecified,
## loading version: 1.087.3
#Grab the lake centroid info
lake_centers <- lagos$locus

Convert to spatial data

#Look at the column names
#names(lake_centers)

#Look at the structure
#str(lake_centers)

#View the full dataset
#View(lake_centers %>% slice(1:100))

spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
                          crs=4326) %>%
  st_transform(2163)

#Subset for plotting
subset_spatial <- spatial_lakes %>%
  slice(1:100) 

subset_baser <- spatial_lakes[1:100,]

#Dynamic mapviewer
mapview(subset_spatial)

Subset to only Minnesota

states <- us_states()

#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
  filter(name == 'Minnesota') %>%
  st_transform(2163)

#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]
minnesota_lakes$state <- "Minnesota"

#Plotting the first 1000 lakes
minnesota_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

In-Class work

1) Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)

#Subset iowa and illinois from whole state dataset

iowaillinois<- states %>%
  filter(name == 'Iowa' | name == "Illinois") %>%
  st_transform(2163)

mapview(iowaillinois)

2) Subset LAGOS data to these sites, how many sites are in Illinois and Iowa

combined? How does this compare to Minnesota?

Illinois and Iowa combined contain 16,466 sites while Minnesota contains 29038 sites!

#Subset iowa and illinois lakes based on spatial position
iowaillinois_lakes <- spatial_lakes[iowaillinois,]

count_iowaillinois_lakes <- sum(!is.na(iowaillinois_lakes$nhdid))

count_minnesota_lakes <- sum(!is.na(minnesota_lakes$nhdid))

print(count_iowaillinois_lakes)
## [1] 16466
print(count_minnesota_lakes)
## [1] 29038

3) What is the distribution of lake size in Iowa vs. Minnesota?

  • Here I want to see a histogram plot with lake size on x-axis and frequency on y axis (check out geom_histogram)

?geom_histogram

#Extract Iowa from larger states dataset (Minnesota lakes have been extracted)
iowa<- states %>%
  filter(name == 'Iowa') %>%
  st_transform(2163)
iowa_lakes <- spatial_lakes[iowa,]
iowa_lakes$state <- "Iowa"

#Plot histogram of lake area frequency across iowa and minnesota lakes
ia_mn_lakes <- rbind(iowa_lakes, minnesota_lakes)

ggplot(data=ia_mn_lakes, aes(log(lake_area_ha), color=state)) +
  xlab(" Lake Area (Log Hectare)") +
  ylab("Frequency") +
  ggtitle("Lake Area Frequency in IA and MN") +
  geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

4) Make an interactive plot of lakes in Iowa and Illinois and color them

by lake area in hectares

#Plotting the first 1000 lakes in Iowa and Illinois
iowaillinois_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

5) What other data sources might we use to understand how reservoirs and

natural lakes vary in size in these three states?

Each state likely has GIS data which could be used to further assess lake size variation.USGS also has water data for the nation which may contain lake data for the three states we are analyzing.